import axios from 'axios';
// axios.defaults.baseURL='https://api.douban.com/v2'

//获取电影通用方法
const getMovieList=(type)=>{
    return axios.get(`/v2/movie/${type}`).then(res => {
        return res.data.subjects;
    }); 
}
//搜索电影
const searchMovie=(keyword)=>{
    return axios.get(`/v2/movie/search?q=${keyword}`).then(res => {
        return res.data.subjects;
    }); 
}
//获取电影详情
export const getMovieDetail=(movieId)=>{
    return axios.get(`/v2/movie/subject/${movieId}`).then(res => {
        return res.data;
    }); 
}

/*=================================================================*/
//获取本地模拟数据
const getMockList=(type)=>{
    return axios.get(`/v2/movie/${type}`).then(res => {
        return res.data.subjects;
    }); 
}

export {
    in_theaters,
    coming_soon,
    us_box,
    top250,
    getMovieList,
    getMockList,
    searchMovie
}
